<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ taglib prefix="limits" uri="/WEB-INF/tld/limits.tld"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>强切账号管理</title>
<link rel="stylesheet" type="text/css" href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="../../static/js/themes/icon.css">

<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<%
String []nonceObj=ConstantUtils.getNonceObject();
%>
</head>
<body>
	<%-- <input type="hidden" id="sessionId" value="${pageContext.session.id}" /> --%>
	<table id="easyui-datagrid" title="强切账号列表"></table>
	<div id="toolbar" class="easyui_datagrid_toolbar">
		<div class="easyuiSearch">
			<form id="tool_bar_form">
				<table cellspacing="0" cellpadding="0" width="90%">
					<tr>
						<td align="left">账户名称：<input type="text" name="seachName" style="width: 150px;" onkeydown="onpress();"/></td>
						<td align="left">分组名称：<input type="text" name="groupSchedulesName" style="width: 150px;" onkeydown="onpress();"/></td>
						<td align="left">机顶盒账号：<input type="text" name="f_iocs_serverid" style="width: 150px;" onkeydown="onpress();"/></td>
						<td align="left"><a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-search', plain:true" onclick="gotoSearch()">查询</a></td>
					</tr>
					<tr>
						<td align="left">
							客户：<input type="text" id="f_igs_orgName" name="f_igs_orgName" style="width: 150px;" onkeydown="onpress();"/>
							<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0);" onclick="orgSelect()">选择</a>
							<input type="hidden" id="f_igs_orgId" name="f_igs_orgId" value="0"/>
						</td>
						<td align="left">
							<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" plain="true" href="javascript:void(0);" onclick="openGroupSchedulesSelectDialog()">注入分组</a>
							<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" plain="true" href="javascript:void(0);" onclick="parent.addTab('在线统计','industry/behavior_control/online_statistics.jsp','icon')">在线统计</a>
							<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" plain="true" href="javascript:void(0);" onclick="deleteBindOrgServeridGroups()">批量解绑</a>
						</td>
					</tr>
				</table>
			</form>
		</div>
	</div>
	
	<!-- 注入分组选择弹框 easyui-dialog -->
	<div id="dlg" class="easyui-dialog" style="width: 620px; height: 450px; padding-top: 0px;" data-options="title:'内容管理',iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
	</div>

	<div id="org_list" class="easyui-dialog" style="width: 800px; height: 500px; padding-top: 0px;" data-options="title:'客户选择', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0" style="width: 100%; height: 99%;"></iframe>
	</div>


	<script type="text/javascript">
		/* "use strict"; */
		var queryParams;
		var $tool_bar_form = $("#tool_bar_form");
		var $datagrid = $("#easyui-datagrid");
		
		
		function EasyuiDatagrid() {
			$datagrid.datagrid({
				url: '../../industry/behavior/forced_switching_serverid_list.do',
				nowrap: true,
				striped: true,
				border: false,
				fit: true,
				rownumbers:true,
				queryParams: getGueryParams(),
				columns: [[
					{field:'id',checkbox:true},
					{field:'f_iocs_serverid',title:'机顶盒账号',align:'center',width:300,
						formatter:function(value,row,index) {
							return encryption(value);
						}
					},
					{field:'seachName',title:'账号名称',align:'center',width:250,
						formatter:function(value,row,index) {
							return encryption(value);
						}
					},
					{field:'orgName',title:'行业客户',align:'center',width:350},
					{field:'groupSchedulesName',title:'分组名称',align:'center',width:250},
					{field:'_parentId',title:'操作',align:'center',width:150,
						formatter:function(value,row,index){
							var str ="";
                            <limits:uiAuth url="online_statistics.jsp">
							str= '<a class="easyui-linkbutton l-btn l-btn-plain" iconCls="icon-ok" href="javascript:void(0);" plain="true" onclick="showDetail(\''+row.f_iocs_serverid+'\');" ><span class="l-btn-left"><span class="l-btn-text icon-edit l-btn-icon-left">详情</span></span></a>';
							</limits:uiAuth>
							return str;
						}
					}
				]],
				singleSelect:false,
				pagination:true,
				pageList:[10,20,30,40,50],
				pageSize:10,
				toolbar: '#toolbar'
			});
		}
	
		function getGueryParams(){
			return {
				orgName : $tool_bar_form.find("input[name='f_igs_orgName']").val(),
				f_iocs_orgId : $tool_bar_form.find("input[name='f_igs_orgId']").val(),
				seachName: $tool_bar_form.find("input[name='seachName']").val(),
				groupSchedulesName : $tool_bar_form.find("input[name='groupSchedulesName']").val(),
				f_iocs_serverid : $tool_bar_form.find("input[name='f_iocs_serverid']").val()
			};
		}
		
		new EasyuiDatagrid();
		var gotoSearch = function(){
			$datagrid.datagrid('reload',getGueryParams());
		};
		
		function onpress(){
			var event=arguments.callee.caller.arguments[0]||window.event;//消除浏览器差异
				if (event.keyCode == 13){  
				gotoSearch();
			}
		}
			
		function showDetail(serverid) {
			parent.addTab('在线统计' + serverid, 'industry/behavior_control/online_statistics.jsp?serverId=' + serverid, 'icon');
		}
		
		function orgSelect(){
			openDialog($('#org_list'),'org_update.jsp?idField=f_igs_orgId&nameField=f_igs_orgName');
		}
		
		function openGroupSchedulesSelectDialog(){
			var selections = $datagrid.datagrid('getSelections');//返回所有被选中的行
			if(selections.length==0) {
				alert("请至少选择一行数据");
				return false;
			}else{
				var selectionsObj = JSON.stringify( selections );
				openDialog($('#dlg'), 'group_schedules_list_dialog.jsp?selectionsObj=' + encodeURIComponent(selectionsObj));
			}
			//原单条数据的处理方式
			//openDialog($('#dlg'), 'group_schedules_list_dialog.jsp?serverid=' + selections[0].f_iocs_serverid + "&orgId=" + selections[0].f_iocs_orgId + "&f_iocs_igsId=" + selections[0].f_iocs_igsId);
		}
		
		function deleteBindOrgServeridGroups(){
			var selections = $datagrid.datagrid('getSelections');//返回所有被选中的行
			if(selections.length==0) {
				alert("请至少选择一行数据");
				return false;
			}
			var selectionsObj = JSON.stringify( selections );
			$.ajax({
				url: '../../industry/behavior/bind_org_serverid_groups.do',
				data: {
					industryGroupSchedulesVoString : selectionsObj,
					fIocsIgsId : 0,
					deleteOrBindType : 1,
					stime : "<%=nonceObj[0]%>",
					sign : "<%=nonceObj[1]%>"
				},
				dataType: "json",
				type: "GET",
				success: function(data) {
					
					if(data.flag > 0) {
						$('#dlg').dialog('close');
						gotoSearch();
						$.ajax({
							url: "../../cache/clear_web_cache.do",
							type: "GET",
							data: {},
							dataType: "json",
							success: function(data) {}
						});
					} else {
						alert("解绑失败!");
					}
					window.location.reload();
				}
			});
			
		}
		
	</script>

</body>
</html>